﻿namespace HySoft.Cash.Business
{
    using Huayou.Common.Database;
    using Huayou.Utils;
    using HySoft.Cash.BaseClass;
    using HySoft.Cash.DB;
    using HySoft.Cash.Structure;
    using System;
    using System.Data;
    using System.Web.UI;

    public class TuserinfoBN : BaseBusiness
    {
        private TuserinfoDB db;

        public TuserinfoBN(Page page) : base(page)
        {
            this.db = null;
            this.db = new TuserinfoDB(base.curDBOperater);
        }

        public TuserinfoBN(Page page, DBOperate oper) : base(page, oper)
        {
            this.db = null;
            this.db = new TuserinfoDB(base.curDBOperater);
        }

        public bool Add(TuserinfoDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Add(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public bool Delete(int Sid)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Delete(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public void Dispose()
        {
            base.Dispose();
            if (this.db != null)
            {
                this.db = null;
            }
        }

        public bool Edit(TuserinfoDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Edit(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public TuserinfoDT Get(int Sid)
        {
            TuserinfoDT odt = null;
            try
            {
                try
                {
                    odt = this.db.Get(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return odt;
        }

        public DataTable GetList()
        {
            base.DBFieldList = "Sid,Username,Password,RuleSid,PubDate,IsOpen";
            base.DBTable = "tUserInfo";
            return base.CommonGetList();
        }

        public void QueryIsOpen(int IsOpen)
        {
            base.Filter = "IsOpen= " + IsOpen;
        }

        public void QueryPassword(string Password)
        {
            if ((Password != null) && (Password.Trim() != ""))
            {
                base.Filter = "Password like '%" + StringUtils.ToSQL(Password) + "%'";
            }
        }

        public void QueryPubDate(DateTime PubDate)
        {
            base.Filter = "PubDate= " + PubDate;
        }

        public void QueryRuleSid(int RuleSid)
        {
            base.Filter = "RuleSid= " + RuleSid;
        }

        public void QuerySid(int Sid)
        {
            base.Filter = "Sid= " + Sid;
        }

        public void QueryUsername(string Username)
        {
            if ((Username != null) && (Username.Trim() != ""))
            {
                base.Filter = "Username like '%" + StringUtils.ToSQL(Username) + "%'";
            }
        }
    }
}

